package org.datascooter.tansaction;

import org.datascooter.impl.DataSnip;
import org.datascooter.inface.IDataManager;

/**
 * One task of transaction - one DataSnip must be executed in one dataManager
 * 
 * @author nemo
 * 
 */
public class Task {

	private DataSnip dataSnip;
	private IDataManager dataManager;

	public Task(IDataManager dataManager, DataSnip dataSnip) {
		this.dataManager = dataManager;
		this.dataSnip = dataSnip;
	}

	public void beginTransaction(String transactionId) {
		dataManager.beginTransaction(transactionId);
	}

	public void run() {
		dataManager.execute(dataSnip);
	}

	public void commit() {
		dataManager.commit();
	}

	public void requestCommit() {
		dataManager.requestCommit();
	}

	public void rollback() {
		dataManager.rollback();
	}
}
